<!DOCTYPE html>
<html lang="zh-CN"
      xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>添加后台管理员</title>
    <link rel="stylesheet" th:href="@{/layui/css/layui.css}">
    <script th:src="@{/layui/jquery.min.js}"></script>
    <style type="text/css">
        .layui-input{
            width: 300px;
            margin-top: 10px;
        }
    </style>
</head>
<body>

    <p style="color: red" id="add-msg"></p>
    <div class="layui-form-item">
        <label class="layui-form-label">用户名</label>
        <div class="layui-input-block">
            <input type="text" id="adminName" name="adminName" required  lay-verify="required" placeholder="请输入用户名!" value="" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">密码</label>
        <div class="layui-input-block">
            <input type="password" id="password" name="password" required  lay-verify="required" placeholder="请输入密码!" value="" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">确认密码</label>
        <div class="layui-input-block">
            <input type="password" id="repassword" name="repassword" required  lay-verify="required" placeholder="请确认密码!" value="" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">真实姓名</label>
        <div class="layui-input-inline">
            <input type="text" id="realname" name="realname" required lay-verify="required" placeholder="请输入真实姓名!" value="" autocomplete="off" class="layui-input">
        </div>
        <div class="layui-form-mid layui-word-aux"></div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" onclick="addAdminSubmit()">立即添加</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>

<script th:src="@{layui/layui.js}" charset="utf-8"></script>
<script type="text/javascript" th:src="@{/shoppingApi/js/jquery-3.3.1.min.js}"></script>
<script type="application/javascript" th:src="@{/shoppingApi/js/common.js}"></script>
<script>
    function addAdminSubmit() {
        var adminName = $("#adminName").val();
        var password = $("#password").val();
        var realname = $("#realname").val();
        $.ajax({
            type:'post',
            url:'/saveAddAdmin',
            data:{
                adminName: adminName,
                password: password,
                realname: realname
            },
            success:function (res) {
              if(res.msg=='1'){
                 alert("增加成功！");
              }  else{
                  alert("增加失败！");
              }
            }

        })

    }
</script>


</body>
</html>